package com.itheima.controller;

import com.itheima.dao.UserDao;
import com.itheima.pojo.Address;
import com.itheima.pojo.Result;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import com.itheima.service.UserServiceImplA;
import com.itheima.util.XmlParserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/*
IOC DI
 */

@RestController //= @Controller + @ResponseBody
public class UserController {
    //创建UserService
    @Autowired
    private UserService userService ;

    @Autowired
    @Qualifier("userDaoImplA")
    private UserDao userDao;

    @RequestMapping("/listUser")
    public Result listUser() {
        //调用业务层获取数据
        //List<User> data = userService.listUser();
        List<User> data = userDao.listUser();

        //3 返回数据
        return new Result(1, "success", data);
    }
}
